package com.qf.flashlib.app;

import android.app.Application;

import com.qf.flashlib.http.LoggerUtil;
import com.tencent.smtt.sdk.QbSdk;

public abstract class BaseApp extends Application {

    protected static BaseApp app;
    public static BaseApp getInstance() {
        return app;
    }

    private MyActivityLifecycleCallbacks activityLifecycleCallbacks = new MyActivityLifecycleCallbacks();

    @Override
    public void onCreate() {
        super.onCreate();
        init();
        app = this;
    }

    private void init() {
        initSDK();
        initLogger();
        //初始化Lib包
        FlashLib.onCreate(this);
        //初始化X5内核
        initX5Web();
        registerActivityLifecycleCallbacks(activityLifecycleCallbacks);
    }



    protected abstract void initSDK();


    /**
     * 初始化X5内核
     */
    private void initX5Web()
    {
        QbSdk.initX5Environment(getApplicationContext(), null);
    }


    /**
     * 初始化Logger打印
     */
    private void initLogger()
    {
        LoggerUtil.init("HTTP_LOG_TAG", 0, false, 0);
    }



    public MyActivityLifecycleCallbacks getActivityLifecycleCallbacks() {
        return activityLifecycleCallbacks;
    }
}
